package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.AnnouncementMapper;
import com.tanhua.dubbo.mappers.UserInfoMapper;
import com.tanhua.model.domain.Announcement;
import com.tanhua.model.vo.PageResult;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class AnnouncementApiImpl implements  AnnouncementApi{

    @Autowired
    private AnnouncementMapper announcementMapper;

    @Override
    public IPage<Announcement> findAnnouncements(Integer page, Integer pagesize) {

        LambdaQueryWrapper<Announcement> qw = new LambdaQueryWrapper<>();
        qw.orderByDesc(Announcement::getCreated);
        IPage<Announcement> pageInfo = new Page<>(page,pagesize);
        IPage<Announcement> iPage = announcementMapper.selectPage(pageInfo, qw);
        return iPage;
    }
}
